package org.duang.plugins;

import java.lang.annotation.Annotation;
import java.util.HashMap;
import java.util.Map;

import org.duang.aop.Proxy;
import org.duang.config.InstanceFactory;
import org.duang.ioc.Lock;
import org.duang.ioc.Mq;
import org.duang.ioc.Tx;
import org.duang.proxy.LockProxy;
import org.duang.proxy.MqProxy;
import org.duang.proxy.TxProxy;

public class ProxyPlugin implements IPlugin {

	private ProxyPlugin() {
		
	}
	
	private static ProxyPlugin instance = new ProxyPlugin();
	public static  ProxyPlugin getInstance() {
		return instance;
	}
	
	public void start() throws Exception{
		Map<Class<? extends Annotation>,Class<? extends Proxy>> annotAtionMap = new HashMap<Class<? extends Annotation>,Class<? extends Proxy>>();
		annotAtionMap.put(Lock.class, LockProxy.class);
		annotAtionMap.put(Tx.class, TxProxy.class);
		annotAtionMap.put(Mq.class, MqProxy.class);
		InstanceFactory.setAnnotation(annotAtionMap);
	}

	public void stop() throws Exception{
		InstanceFactory.getAnnotation().clear();
	}

}
